package com.glory.hzlionpda.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.hzlionpda.R;
import com.glory.hzlionpda.bean.MateriaBean;
import com.glory.hzlionpda.callback.ChangeCallback;

import java.util.List;


public class EqpThingListAdapter extends BaseQuickAdapter<MateriaBean, BaseViewHolder> {
    private ChangeCallback changeCallback;

    public EqpThingListAdapter(@Nullable List<MateriaBean> data) {
        super(R.layout.adapter_eqp_thing_list, data);
    }

    public void setCallBack(ChangeCallback callBack) {
        this.changeCallback = callBack;
    }

    @Override
    protected void convert(BaseViewHolder helper, final MateriaBean item) {
        helper.setText(R.id.tvName, item.getMATERIANAME());
        helper.setText(R.id.tvCode, item.getMATERIAVALUE());
        Button btnChange = helper.getView(R.id.btnChange);
        btnChange.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                changeCallback.onSuccess(item);
            }
        });
    }
}
